import axios from 'axios'
import './request.js'

// 获取密码登录验证码
export const getCheckPic = function () {
  return axios.post('/checkcode/pic')
}

// 验证密码登录验证码
export const reCheckPic = function (params) {
  return axios.post('/checkcode/verify', params)
}

// 用户密码登录
export const userLogin = function (params) {
  return axios.post('/auth/oauth/token', params)
}

// 获取手机验证码
export const getPhoneCode = function (params) {
  return axios.post('/auth/user/ssm', params)
}

// 手机验证码登录
export const phoneLogin = function (params) {
  return axios.post('/手机登录', params)
}

// 我的公益
export const getMyPublic = function () {
  return axios.get('/content/usernice/list')
}

// 参与公益
export const getAddPublic = function (params) {
  return axios.post('/content/usernice/add', params)
}

// 获取系统通知
export const getNotice = function () {
  return axios.get('/content/info/get')
}

// 获取用户信息
export const getUser = function () {
  return axios.get('/content/user/select')
}

const headers = { 'content-Type': 'application/json' }

// 注册用户
export const Register = function (params) {
  return axios.post('/auth/user/insert', params, { headers: headers })
}

// 修改用户信息
export const updateUser = function (params) {
  return axios.put('/content/user/update', JSON.stringify(params), { headers: headers })
}

// 修改头像
export const updateAvator = function (params) {
  return axios.post('/content/user/upload/file', params)
}

// 积分兑换商品
export const changeGood = function (params) {
  return axios.post('/content/user/buy', JSON.stringify(params), { headers: headers })
}

// 创建废品订单
export const createOrder = function (params) {
  return axios.put('/content/waste/createIndent', params, { headers: headers })
}

// 所有积分商品订单
export const ShopOrder = function (params) {
  return axios.get('/content/user/buyHistory')
}

// 所有废品订单
export const WasteOrder = function (params) {
  return axios.get('/content/waste/indent')
}

// 积分收入
export const getPointlist = function (params) {
  return axios.get(`/content/user/pointAdjust/${params}`)
}
